﻿namespace Flowertwig.Utils.Events
{
    public class DefaultEventArgs : EventArgs<int, object>
    {
        public DefaultEventArgs() : base(0, null) {}
        /// <summary>
        /// Initializes a new instance of this EventArgs
        /// </summary>
        /// <param name="action">Action that has/should be performed</param>
        public DefaultEventArgs(int action) : base(action, null) { }
        /// <summary>
        /// Initializes a new instance of this EventArgs
        /// </summary>
        /// <param name="action">Action that has/should be performed</param>
        /// <param name="data">Object that is used to give more info about the action.</param>
        public DefaultEventArgs(int action, object data) : base(action, data) { }
    }


    /// <summary>
    /// Provides data for the internal events.
    /// </summary>
    public class EventArgs<TAction, TData> : System.EventArgs
    {
        protected TAction _action;
        protected TData _data;
        protected bool _handled;

        /// <summary>
        /// Initializes a new instance of this EventArgs
        /// </summary>
        /// <param name="action">Action that has/should be performed</param>
        public EventArgs(TAction action) : this(action, default(TData)) { }
        /// <summary>
        /// Initializes a new instance of this EventArgs
        /// </summary>
        /// <param name="action">Action that has/should be performed</param>
        /// <param name="data">Object that is used to give more info about the action.</param>
        public EventArgs(TAction action, TData data)
        {
            _action = action;
            _data = data;
        }

        /// <summary>
        /// Gets Action that has/should be performed.
        /// </summary>
        public TAction Action
        {
            get { return _action; }
        }
        /// <summary>
        /// Gets/sets object that is used to give more info about action.
        /// </summary>
        public TData Data
        {
            get { return _data; }
            set { _data = value; }
        }
        /// <summary>
        /// Gets/sets if this even has already been handled by someone else.
        /// </summary>
        public bool Handled
        {
            get { return _handled; }
            set { _handled = value; }
        }
    }
}